<template>
	<view class="headmain" v-show="PageCur!='my'">
		<view class="back_img" v-show="showBack!=true" @click="Back">
			<image src="../../static/icon/back1.png" mode=""></image>
		</view>
		<view v-show="PageCur=='zhaopin1'">
			<view class="headmain_left" @click="getCity">
				<image src="../../static/icon/position.png" mode=""></image>
				<text>{{city}}</text>
			</view>
		</view>
		<text>{{nav}}</text>
	</view>
</template>

<script>
	export default {
		props: [
			"nav", "showBack"
		],
		data() {
			return {
				PageCur: '', //当前导航页面
				cityNow: '', //当前城市
				city: ''
			}
		},
		watch: {
			// 监听切换底部导航时的当前路径
			"$store.state.PageCur"() {
				this.PageCur = this.$parent.PageCur
			},
			"$store.state.newCity"() {
				this.city = this.$store.state.newCity
			}
		},
		created() {

		},
		methods: {

			Back() {
				// 获取页面栈
				let pages = getCurrentPages()

				// 获取上一页栈
				let prevPage = pages[pages.length - 2]
				// 如果是首页实名后进来的，返回的时候直接到首页
				let page2=pages[pages.length-1].$page.fullPath
				// 判断个人中心实名证书动态返回
				let page3=pages[pages.length-2].$page.fullPath
				// 返回职位详情
				
				if(page2=='/common/realName/realName'|| page2=='/common/noRealWaring/waring' || page2=='/common/tenderFile/tenderFile'){
					uni.redirectTo({
						url:'../../pages/home/home'
					})
				}
				else if(page2=='/pageA/certDynamics/certDynamics'){
					uni.redirectTo({
						url:'../../pages/home/home?PageCur='+'my'
					})
				}
				else if(page2=='/common/realName/nowReal'){
					uni.redirectTo({
						url:'../../pages/home/home?PageCur='+'my'
					})
				}
				else{
					// 触发上一页 upData 函数(并携带参数)
					prevPage.$vm.test()
					uni.navigateBack()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.headmain {
		width: 100%;
		width: 750rpx;
		// background: #ffffff;
		z-index: 9999;
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;

		.back_img {
			width: 48rpx;
			height: 48rpx;
			position: absolute;
			top: 12rpx;
			left: 36rpx;

			image {
				width: 50%;
				height: 64%;
			}
		}

		.headmain_left {
			display: flex;
			position: absolute;
			left: 26rpx;
			top: 16rpx;

			image {
				width: 32rpx;
				height: 36rpx;
				margin-right: 10rpx;
			}

			text {
				font-size: 22rpx;
				font-family: PingFang SC, PingFang SC-Medium;
				font-weight: 500;
				text-align: left;
				color: #333333;
			}
		}

		text {
			font-size: 36rpx;
			font-family: PingFang SC, PingFang SC-Medium;
			font-weight: 500;
			text-align: center;
			color: #333333;
		}
	}
</style>
